package com.snimay.app.login;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.snimay.app.login.repository.LoginRepository;
import com.snimay.app.login.vo.Login;
import com.snimay.common.RestServiceController;
import com.snimay.util.ToWeb;

/**   
 * @Title      : LoginController.java
 * @Package    : com.snimay.app.login
 * @Description: TODO 
 * @author     : xxy
 * @date       : 2018年5月2日 上午10:32:05
 * @version    : V1.0   
 */
@RestController
@RequestMapping("login")
public class LoginController implements RestServiceController<Login, Long>{
	
	@Autowired
	LoginRepository repository;
	
	/**
	 * @Description: TODO
	 * @author     : xxy
	 * @param id
	 * @return
	 * @throws
	 */
	@Override
	@GetMapping("/{id}")
	public Object getOne(@PathVariable("id") Long id) {
		ToWeb toweb = new ToWeb();
		toweb.setObjData(repository.findOne(id));
		return new Gson().toJson(toweb);
	}

	@Override
	@GetMapping
	public Object getList(@RequestParam(value = "rowSize",defaultValue = "100", required = false) Integer rowSize
            , @RequestParam(value = "page", defaultValue = "1", required = false) Integer page) {
		ToWeb toweb = new ToWeb();
		toweb.setObjData(repository.findAll());
		return new Gson().toJson(toweb);
	}

	@Override
	@PostMapping
	public Object postOne(@RequestBody Login entity) {
		// TODO Auto-generated method stub
		return null;
	}

    @Override
	@PutMapping("/{id}")
	public Object putOne(@PathVariable("id") Long id,@RequestBody Login entity) {
		// TODO Auto-generated method stub
		return null;
	}

    @Override
	@PatchMapping("/{id}")
	public Object patchOne(Long id, Login entity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object deleteOne(Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	 
}
